<?php
namespace interface\v1;
/*
*待办事项接口类
*/

class backlogAppClass extends index
{
    private const title = '待办事项接口类';
    /*待办事项列表*/
    public function list()
    {
        //数据查询
        $date = date("Y-m-d");
        $where = " stid = '" . $this->control['stid'] . "' and startDay <= '$date' ";
        $page = $this->page(array("table" => "backlog", "where" => $where,'num'=>20, "order" => "FIELD(workFlow,'待处理','已完成'),FIELD(urging,'是','否'),startDay desc"));
        //数据分析
        $data['result'] = [];
        foreach ($page['array'] as $array) {
            if (empty($array['targetCla']) && empty($array['targetFun'])){
                $audit = query('audit',"id = '$array[typeId]'");
                $array['typeId'] = $audit['targetId'];
            }
            $data['result'][] = array(
                "id" => $array['id'],//待办事项ID
                "type" => $array['type'],//类型
                "typeId" => $array['typeId'],//对象表ID
                "text" => $array['text'],//待办事项说明
                'workFlow'=>$array['workFlow'],
                'urging' => $array['urging'],
                'url' =>  oaIndexAppClass::navigateTo($array['type'],$array['typeId']),
                "time" => $array['time'],//创建时间
            );
        }
        //返回
        $data['page'] = $page['para'];
        //返回
        $this->code = 1;
        $this->resp['data'] = $data;
    }
}
